package com.example.article.controller;

import com.example.article.service.ArticleService;
import com.usian.model.article.dtos.ApArticleCheckedDto;
import com.usian.model.article.dtos.ApArticleDto;
import com.usian.model.article.pojos.ApAuthor;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmNewsDtos;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Slf4j
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    @PostMapping("article/v1/add_article")
    public Integer addArticle(@RequestBody WmNewsDtos wmNewsDtos){
        return articleService.addArticle(wmNewsDtos);
    }
    @GetMapping("article/v1/get_article")
    public ResponseResult getArticle(ApArticleDto apArticleDto){
        return articleService.getAricle(apArticleDto);
    }
    @PostMapping("/article/v1/get_article")
    public ResponseResult getArticle(long id){
        return articleService.getArticleById(id);
    }
    @PostMapping("article/v1/get_apauthor")
    public ApAuthor getApAuthor(@RequestBody ApArticleCheckedDto apArticleCheckedDto){
        return articleService.getApAuthor(apArticleCheckedDto.getAuthorId());
    }
}
